﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;
namespace MDFGame
{

    /// <summary>
    /// 卡牌效果工厂
    /// </summary>
    public static class EffectFactory
    {
        /// <summary>
        /// 使用名称获取卡牌对应的效果实现
        /// </summary>
        /// <param name="name">卡名缩写[RM-1]，角色卡则[RM-C-1]</param>
        /// <returns></returns>
        public static ICardEffect GetCardEffect(string name)
        {
            GlobalComponent _temp = GameRoot.Scene.GetComponent<GlobalComponent>();
            if (_temp.CardEffectDic != null)
            {
                ICardEffect cardEffect = Activator.CreateInstance(_temp.CardEffectDic[name]) as ICardEffect;
                if (cardEffect == null)
                {
                    Log.Error($"卡片{name}效果未能实现ICardEffect接口");
                    return null;
                }
                return cardEffect;
            }
            return null;
        }
    }
}
